package com.novabluetooth.services.ktxyj;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

import android.util.Log;

/**
 * 获取血压数据
 * 
 * @author nova
 *
 */
public class DeviceData {
	private static final long serialVersionUID = 1L;
	private int m_lowPre;// 低压
	private int m_hiPre;// 高压
	private int m_ml;// 脉率
	private int m_pjy;// 平均压
	private int m_nTC;
	private Date mSaveDate;
	public static ArrayList<DeviceData> m_deviceDataList = new ArrayList<DeviceData>();
	private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public DeviceData() {
	}

	public DeviceData(byte[] _byte) {
		Log.e("_byte-----------", Arrays.toString(_byte));
		if (_byte.length > 0) {

			DeviceData deviceData = new DeviceData();
			int lowPre = _byte[2] & 0xff; // 低压
			int hiPre = (_byte[0] << 8 | _byte[1]) & 0xffff;
			int ml = _byte[3] & 0xff; // 脉率
			int pjy = _byte[4] & 0xff; // 平均压
			int year = _byte[5] & 0xff; // 年
			int month = _byte[6] & 0xff; // 月
			int day = _byte[7] & 0xff; // 日
			int hours = _byte[8] & 0xff; // 时
			int min = _byte[9] & 0xff; // 分
			int seconds = _byte[10] & 0xff; // 秒

			deviceData.setM_hiPre(hiPre);
			deviceData.setM_lowPre(lowPre);
			deviceData.setM_ml(ml);
			deviceData.setM_pjy(pjy);
			deviceData.setmSaveDate(new Date(year, month, day, hours, min, seconds));
			m_deviceDataList.add(deviceData);
		}

	}

	public static void printDatas() {
		for (int i = 0; i < m_deviceDataList.size(); i++) {
			DeviceData _DeviceData = m_deviceDataList.get(i);
			Log.i("com.testbluetooth", "测试时间：" + dateFormat.format(_DeviceData.getmSaveDate()));
			Log.i("com.testbluetooth", "数据：高压＝" + _DeviceData.getM_hiPre() + "低压＝" + _DeviceData.getM_lowPre() + "平均压＝"
					+ _DeviceData.getM_pjy() + "脉率=" + _DeviceData.getM_ml());
		}
	}

	public int getM_lowPre() {
		return m_lowPre;
	}

	public void setM_lowPre(int m_lowPre) {
		this.m_lowPre = m_lowPre;
	}

	public int getM_hiPre() {
		return m_hiPre;
	}

	public void setM_hiPre(int m_hiPre) {
		this.m_hiPre = m_hiPre;
	}

	public int getM_ml() {
		return m_ml;
	}

	public void setM_ml(int m_ml) {
		this.m_ml = m_ml;
	}

	public int getM_pjy() {
		return m_pjy;
	}

	public void setM_pjy(int m_pjy) {
		this.m_pjy = m_pjy;
	}

	public int getM_nTC() {
		return m_nTC;
	}

	public void setM_nTC(int m_nTC) {
		this.m_nTC = m_nTC;
	}

	public Date getmSaveDate() {
		return mSaveDate;
	}

	public void setmSaveDate(Date mSaveDate) {
		this.mSaveDate = mSaveDate;
	}

	public static ArrayList<DeviceData> getM_deviceDataList() {
		return m_deviceDataList;
	}

	public static void setM_deviceDataList(ArrayList<DeviceData> m_deviceDataList) {
		DeviceData.m_deviceDataList = m_deviceDataList;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

}
